package com.miracle.controller;

import com.miracle.common.response.Result;
import com.miracle.common.response.ResultInfo;
import com.miracle.entity.Menu;
import com.miracle.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jie.xi
 * @date 2022年05月20日 11:20
 */

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;



    @GetMapping("/getMenu")
    public Result getMenuListByUserRole(@RequestParam("roleName") String roleName){
        List<Menu> menuListByUserRole = menuService.getAllMenuList(roleName);
        if (menuListByUserRole.size()>0){
            return Result.success().codeAndMessage(ResultInfo.SUCCESS).data("menuList",menuListByUserRole);
        }else {
            return Result.error();
        }
    }
}
